package satir.card.factory;

import org.json.JSONObject;

import satir.card.Card;
import satir.framework.refectoring.Factory;

/**
 * A factory for creating Card objects.
 * @version 3.0 April 2012
 * @author Creative Family
 */
public abstract class CardFactory implements Factory {

    /** The card json. */
    protected JSONObject cardJson;

    /**
     * Creates a new Card object.
     * @return the card
     */
    public abstract Card createCard();

    /**
     * Sets the card detail.
     * @param cardJson
     *            the new card detail
     */
    public void setCardDetail(final JSONObject cardJson) {
	this.cardJson = cardJson;
    }

    /**
     * Creates the card.
     * @param json
     *            the JSON object
     * @return the object
     * @throws FactoryException
     *             the factory exception
     * @see Factory, LazyInitiator
     */
    @Override
    public Object create(final JSONObject json) throws FactoryException {
	setCardDetail(json);
	return createCard();
    }
}
